import { request } from "@/utils/request";
import type { ResponseBody } from "@/api/typing";
import type {
  DeleteApiParams,
  DeleteParams,
  PermissionApiParams,
  PermissionParams,
  QueryApiParams,
  QueryApiResult,
  QueryParams,
  QueryResult,
} from "./typing";

/**新增权限 */
export const add = (params: PermissionParams) => {
  return request.post<PermissionParams, ResponseBody>(
    "/permission/add",
    params
  );
};

/**修改权限 */
export const update = (params: PermissionParams) => {
  return request.put<PermissionParams, ResponseBody>(
    "/permission/update",
    params
  );
};

/**列表查询权限 */
export const queryByList = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<QueryResult[]>>(
    "/permission/list",
    { params }
  );
};

/**删除权限 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/permission/delete", {
    params,
  });
};

/**新增权限接口 */
export const addApi = (params: PermissionApiParams) => {
  return request.post<PermissionApiParams, ResponseBody>(
    "/permission/api/add",
    params
  );
};

/**修改权限接口 */
export const updateApi = (params: PermissionApiParams) => {
  return request.put<PermissionApiParams, ResponseBody>(
    "/permission/api/update",
    params
  );
};

/**列表查询权限 */
export const queryApiByList = (params: QueryApiParams) => {
  return request.get<QueryApiParams, ResponseBody<QueryApiResult[]>>(
    "/permission/api/list",
    { params }
  );
};

/**删除权限 */
export const delApi = (params: DeleteApiParams) => {
  return request.delete<DeleteApiParams, ResponseBody>(
    "/permission/api/delete",
    {
      params,
    }
  );
};
